<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>全部方案</title>
<link rel="stylesheet" type="text/css" href="../css/blueprint/screen.css" media="screen, projection"/>
<link rel="stylesheet" type="text/css" href="../css/blueprint/plugins/buttons/screen.css" media="screen, projection"/>
<script type="text/javascript" src="../script/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../script/jquery.plugin.tablecross-0.1.js"></script>
<script type="text/javascript" src="../script/jquery.plugin.pageit-0.1.js"></script>
<script type="text/javascript" src="../script/jquery.plugin.ajaxtip-0.1.js"></script>
<script type="text/javascript">
	var queryVO = {unit: "", orderType: "RegisterID desc"};
	var planId;
    $(document).ready(function() {
    	$("#planDataTable").ajaxProccessTip();
    	getPlanData(queryVO, 1, 10);
    	$("#pageBar").pageListener(getPlanData, queryVO);
    	$(".sort-head").sortListener(getPlanData, queryVO, "../images/arrow_up.png", "../images/arrow_down.png");
    	$("#QUERY_SELECT").change(function() {
	    	if ($(this).val() == "unit") {
	        	$("#QUERY_TD").html('<input type="text" value="" id="QUERY_CONDITION" />');
	    	}
    	});
    	$("#QUERY_BUTTON").click(function() {
			var select = $("#QUERY_SELECT").val();
			var condition = $("#QUERY_CONDITION").val();
			if (select == "unit") {
				queryVO.unit = condition;
			}
			getPlanData(queryVO, 1, 10);
		});
		$(".zzbb-button").live("click", function() {
			planId = $(this).attr("planid");
			$.ajax({
				type: "post",
				url: "ZZBB.action",
				dataType: "json",
				data: {"planId": planId},
				success: function(data) {
					if (data.returnCode == "success") {
						alert("操作成功");
						getPlanData(queryVO, $("#page_index").val(), $("#page_size").val());
					} else {
						alert("操作失败");
					}
				}
			});
		});
		$(".unzzbb-button").live("click", function() {
			planId = $(this).attr("planid");
			$.ajax({
				type: "post",
				url: "UNZZBB.action",
				dataType: "json",
				data: {"planId": planId},
				success: function(data) {
					if (data.returnCode == "success") {
						alert("操作成功");
						getPlanData(queryVO, $("#page_index").val(), $("#page_size").val());
					} else {
						alert("操作失败");
					}
				}
			});
		});
    });

    function getPlanData(queryVO, pageIndex, pageSize) {
    	$.ajax({
            type: "post",
            url: "ListAllPlan.action",
            data: {"queryVO.unit": queryVO.unit, "queryVO.orderType": queryVO.orderType, "pageVO.pageIndex": pageIndex, "pageVO.pageSize": pageSize},
            dataType: "json",
            success: function(data) {
            	if (data == null) {
                    alert('非法的请求，请确认你是否有权限执行该操作，请重新登录。');
                    window.parent.location.href="../j_spring_security_logout";
                    return;
                }
                var strArr = new Array();
                for (var i = 0; i < data.planList.length; i++) {
                    strArr.push('<tr>');
                    strArr.push('<td>' + data.planList[i].registerid + '</td>');//项目登记号
                    strArr.push('<td>' + data.planList[i].prjUnit + '</td>');//项目单位
                    strArr.push('<td>' + data.planList[i].prjName + '</td>');//项目名称
                    strArr.push('<td>' + data.planList[i].prjScztName + '</td>');//审查状态 
                    strArr.push('<td>' + (data.planList[i].prjPsjgName != null ? data.planList[i].prjPsjgName : "") + '</td>');//评审结果
                    strArr.push('<td>' + (data.planList[i].zzbb == "1" ? "已备案" : "未备案") + '</td>');//纸质报备状态  
                    strArr.push('<td>' + '<a href="JudgedPlanDetailPre.action?planId=' + data.planList[i].prjPkid + '" target="MainFrame" class="button"><img src="../css/blueprint/plugins/buttons/icons/table.png" alt=""/>明细</a>');
                    if (data.planList[i].zzbb != "1") {
                    	strArr.push('<button class="zzbb-button" type="button" planid="' + data.planList[i].prjPkid + '">纸质报备</button>');
                    } else {
                    	strArr.push('<button class="unzzbb-button" type="button" planid="' + data.planList[i].prjPkid + '">取消纸质报备</button>');
                    }
                    strArr.push('</td>');
                    strArr.push('</tr>');
                }
                $("#planDataBody").html(strArr.join(''));
                $("#planDataBody").tablecross('', 'odd', 'over');
                $("#pageBar").pageRender(data.pageVO.pageIndex, data.pageVO.pageSize, data.pageVO.pageNum);
            }
    	});
    }
</script>
<style type="text/css">
tr.odd td {
    background: #ecf6fc;
}
</style>
</head>
<body>
<table style="margin-bottom: 10px" width="98%" align="center" cellpadding="0" cellspacing="0">
	<tr>
        <td width="15" style="padding: 0px" align="left">
		    <select id="QUERY_SELECT">
		        <option value="unit">项目单位</option>
		    </select></td>
    	<td width="15" id="QUERY_TD"><input type="text" value="" id="QUERY_CONDITION"/></td>
    	<td align="left"><button type="button" id="QUERY_BUTTON"><img src="../css/blueprint/plugins/buttons/icons/magnifier.png" alt=""/>查询</button></td>
    </tr>
</table>
<table id="planDataTable" class="tablesorter" style="margin-top: 0px" width="98%" align="center" cellpadding="2" cellspacing="2">
    <thead>
        <tr>
            <th width="15%" class="sort-head" column="RegisterID">项目登记号</th>
            <th width="12%">项目单位</th>
            <th width="12%">项目名称</th>
            <th width="10%" class="sort-head" column="Prj_SCZTCode">审查状态</th>
            <th width="10%">评审结果</th>
            <th width="8%">备案状态</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody id="planDataBody">
    </tbody>
    <tbody id="pageBar">
        <tr>
            <td colspan="7" nowrap="nowrap" width="100%">
                <table>
                    <tbody>
                        <tr>
                            <td height="25"><button type="button" class="first-page"><img src="../css/blueprint/plugins/buttons/icons/resultset_first.png" alt=""/></button></td>
                            <td><button type="button" class="previous-page"><img src="../css/blueprint/plugins/buttons/icons/resultset_previous.png" alt=""/></button></td>
                            <td width="20%"><span class="page-index-selector" style=""></span></td>
                            <td><button type="button" class="next-page"><img src="../css/blueprint/plugins/buttons/icons/resultset_next.png" alt=""/></button></td>
                            <td><button type="button" class="last-page"><img src="../css/blueprint/plugins/buttons/icons/resultset_last.png" alt=""/></button></td>
                            <td><select class="page-size-selector">
                                    <option value="10" selected="selected">10</option>
                                    <option value="20">20</option>
                                    <option value="30">30</option>
                                </select></td>
                            <td width="80%">&nbsp;</td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
</body>
</html>